<template>
  <el-form :inline="true" :model="params">
    <el-form-item label="管理员编号">
      <el-input v-model="params.id"  disabled placeholder="请输入姓名"></el-input>
    </el-form-item>
    <el-form-item label="姓名">
      <el-input v-model="params.username" placeholder="请输入姓名"></el-input>
    </el-form-item>
    <el-form-item label="联系方式">
      <el-input v-model="params.phone" placeholder="电话号码"></el-input>
    </el-form-item>
    <el-form-item label="邮箱地址">
      <el-input v-model="params.email" placeholder="请输入邮箱"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="update">确定修改</el-button>
      <el-popover
          ref="popover5"
          placement="top"
          width="160">
        <p>确定删除该教务设备吗？</p>
        <div style="text-align: right; margin: 0">
          <el-button type="primary" size="mini" @click="del">确定</el-button>
        </div>
      </el-popover>
      <el-button v-popover:popover5 type="danger" style="margin-left: 5px;">删除</el-button>
    </el-form-item>
  </el-form>
</template>


<script>
import request from "@/utils/request";

export default {
  name: "EditAdmin.vue",
  data() {
    return {
      params: {}
    }
  },
  created() {
    const id = this.$route.query.id
    request.get('/admin/' + id).then(res => {
      this.params = res.data
    })
  },
  methods: {
    del() {
      request.post('/admin/delete', this.params).then(res => {
        if (res.code === '200') {
          this.$notify.success('删除成功')
          this.$router.push("/admin")
        } else {
          this.$notify.error(res.msg + '删除失败')
        }
      })
    },
    update() {
      request.put('/admin/update', this.params).then(res => {
        if (res.code === '200') {
          this.$notify.success('修改成功')
          this.$router.push("/admin")
        } else {
          this.$notify.error(res.msg)
        }
      })
    }
  }
}
</script>

<style scoped>

</style>